{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cb5b0656",
   "metadata": {},
   "source": [
    "-------------------------------------------------------------------------------------------------------------------------------------------\n",
    "* 日期：2022-09-07\\week03（周三）\n",
    "* 课程：python\n",
    "* 记录人：lin"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fc98f004",
   "metadata": {},
   "source": [
    "# 本周学习内容\n",
    "\n",
    ">1.变量\n",
    ">>1.变量的定义和声明\n",
    "\n",
    ">>2.变量名的一般规则\n",
    "\n",
    "\n",
    ">2.编程的控制流\n",
    ">>1.条件判断\n",
    "\n",
    ">>2.循环遍历"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9e14fc2c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4377cc1f",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 变量学习\n",
    "网二_01_ID=\"2110000004\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "22c1e665",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "网二_01_ID\n"
     ]
    }
   ],
   "source": [
    "print(\"网二_01_ID\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "1869485f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'2110000004'"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_01_ID"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "63e39fc2",
   "metadata": {},
   "outputs": [],
   "source": [
    "网二_01_name=\"小白\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "2171fe55",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'小白'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "网二_01_name"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "5ff4e8d5",
   "metadata": {},
   "outputs": [],
   "source": [
    "## 黑客帝国(\"空间\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "16e6be7f",
   "metadata": {},
   "source": [
    "## 2.条件判断"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "fd3afb09",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 课本案例p18"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "075df7d2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Recover, then rest.\n"
     ]
    }
   ],
   "source": [
    "# 变量today需要先赋值\n",
    "today = \"Sunday\"\n",
    "condition = \"Headache\"\n",
    "\n",
    "\n",
    "if today == \"Saturday\":\n",
    "    print(\"Party!\")\n",
    "elif today == \"Sunday\":\n",
    "    if condition == \"Headache\":\n",
    "        print(\"Recover, then rest.\")\n",
    "    else:\n",
    "        print(\"Rest.\")\n",
    "else:\n",
    "    print(\"Work,work,work.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d89573ea",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 练习题： 判断今天是否有python课（time.localtime()),然后如果今天有python课，再判断现在是否是python课ing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "053acbbb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "time.struct_time(tm_year=2022, tm_mon=9, tm_mday=10, tm_hour=1, tm_min=9, tm_sec=42, tm_wday=5, tm_yday=253, tm_isdst=0)"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import time\n",
    "\n",
    "time.localtime()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "63f707de",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "5\n",
      "1\n",
      "13\n",
      "怎么还没到周三呢，唉，等的着急\n"
     ]
    }
   ],
   "source": [
    "# 创建week_day变量,time_hour变量,time_min变量\n",
    "week_day = time.localtime().tm_wday\n",
    "print(week_day)\n",
    "\n",
    "time_hour = time.localtime().tm_hour\n",
    "print(time_hour)\n",
    "\n",
    "time_min = time.localtime().tm_min\n",
    "print(time_min)\n",
    "\n",
    "if week_day == 2:\n",
    "    print(\"今天有python课，好开心呀\")\n",
    "    if time_hour == 19:\n",
    "        print(\"python课ing，刚上课\")\n",
    "    elif time_hour == 18 and time_min > 44:\n",
    "        print(\"python课ing，现在在第二节课了\")\n",
    "    elif time_hour == 20 and time_min < 51:\n",
    "        print(\"python课ing，现在是第三节课了\")\n",
    "    elif time_hour < 18:\n",
    "        print(\"期待今天的课\")\n",
    "    else:\n",
    "        print(\"今天的python课很不错\")\n",
    "else:\n",
    "    print(\"怎么还没到周三呢，唉，等的着急\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "4db06858",
   "metadata": {},
   "source": [
    "# 3.循环遍历\n",
    ">1.for循环\n",
    "\n",
    ">2.rang()方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "37598f48",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n"
     ]
    }
   ],
   "source": [
    "# 用例1 循环迭代数字变量\n",
    "for i in [1,2,3]:\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8fa083e8",
   "metadata": {},
   "source": [
    "* 注意：i是一个变量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "3f6f7769",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "H\n",
      "i\n"
     ]
    }
   ],
   "source": [
    "# 用例2 循环迭代字符串变量\n",
    "for ch in \"Hi\":\n",
    "    print(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "0a0b4d29",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# 用例3 迭代指定的次数\n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d7226979",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "# range 可以创建数据\n",
    "# 用例3 默认从0开始的（start），5是终点（stop），默认步长（step）\n",
    "for num in range(5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b8e480d5",
   "metadata": {},
   "source": [
    "# 4.1强大的range（）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "2b9397c1",
   "metadata": {},
   "outputs": [],
   "source": [
    "### 4.1 关于强大的[range()](https://docs.python.org/3/library/stdtypes.html#range)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "c117c629",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "  # 用例3 扩展1：起点为1      （可以设置起点）\n",
    "for num in range(1,5):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f3c69414",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1\n",
      "3\n",
      "5\n",
      "7\n",
      "9\n"
     ]
    }
   ],
   "source": [
    " # 用例3 扩展2 起点为1  终点为10  步长step 2\n",
    "for num in range(1,10,2):\n",
    "        print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "8d62bb91",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10\n",
      "8\n",
      "6\n",
      "4\n",
      "2\n"
     ]
    }
   ],
   "source": [
    "# 用例3 扩展3\n",
    "for num in range(10,1,-2):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "cdea946d",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "210000001\n",
      "210000004\n",
      "210000007\n",
      "210000010\n",
      "210000013\n",
      "210000016\n",
      "210000019\n",
      "210000022\n",
      "210000025\n",
      "210000028\n",
      "210000031\n",
      "210000034\n",
      "210000037\n",
      "210000040\n",
      "210000043\n",
      "210000046\n",
      "210000049\n"
     ]
    }
   ],
   "source": [
    "# 具体案例\n",
    "for num in range(210000001,210000050,3):\n",
    "    print(num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ddd4cd5a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
